//
//  LoginViewModel.swift
//  loveHHEveryDay
//
//  Created by yw on 2025/4/24.
//

import Foundation


class LoginViewModel:ObservableObject {
    
    func registUser(user:[String:String],completion:(_:(_:String) -> Void)) {
        
        YWNetworkTool.share().requestJson(url: "user/firstRegist", parameters: user,tips: "加载中...") { res in
            DPrint(res)
            guard let result = res as? [String:Any],
                  let status = result["status"] as? Int,
                  let token = result["token"] as? String
            else {
                DPrint("数据解析错误")
                return
            }
            if status == 200 {
                completion(token)
            }
        } responseFailBlock: { err, code in
            DPrint(err)
        }

    }
}
